package com.lcf.framework.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 描述：系统异常
 *
 * @author lcf
 * @since 2025/2/21 15:04
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SysException extends RuntimeException {
    private Integer code;
    private String msg;

    @Override
    public String getMessage() {
        return this.msg;
    }

    public SysException(String msg) {
        this.code = ExceptionEnum.ERROR.getCode();
        this.msg = msg;
    }

    public SysException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SysException(ExceptionEnum e) {
        this.code = e.getCode();
        this.msg = e.getMsg();
    }

    public SysException(Exception e) {
        this.code = ExceptionEnum.ERROR.getCode();
        this.msg = e.getMessage();
    }
}
